package com.example.zte.myapplication;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class ListActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_list);
               ListView listView =
                (ListView) findViewById(R.id.listview1);
        //定义一个数组，用来填充listview
        String[] arr = {"章节1", "章节2", "章节3"};
        ArrayAdapter<String> adapter = new ArrayAdapter<String>
                (this, android.R.layout.simple_expandable_list_item_1, arr);

        //为listview设置adapter
        listView.setAdapter(adapter);

    }
}
